<!doctype html>
<html lang="en">
<head>
    @include('web.layout.head')
    <link rel="stylesheet" href="{{asset('/css/web/user/order_list.css')}}">
    <link rel="stylesheet" href="{{asset('/css/web/user/report_add.css')}}">
</head>
<body>
@include('web.layout.header')
@include('web.layout.user_tab')
<div class="base_member_content">
    <div class="w1200">
        @include('web.layout.buyer_nav')
        <div class="nav_right flr">
            <div class="base_content">
                <form id="postForm" method="post" >
                    <div class="line_title">新增举报</div>
                    <div class="report_center">
                        <div class="report_type">
                           <p class="type_titlle">举报类型：</p>
                           <select class="type_choise" name="report_type_id">
                               @foreach($list as $v)
                              <option value="{{$v['id']}}">{{$v['name']}}</option>
                                   @endforeach
                           </select>
                        </div>
                        <div class="report_type report_goods">
                           <p class="type_titlle goods_titlle">举报商品：</p>
                           <input class="goods_name" type="text" name="product_name"  maxlength="32">
                        </div>
                        <div class="report_type report_store">
                           <p class="type_titlle">举报店铺：</p>
                           <input class="goods_name store_name" type="text" name="shop_name" maxlength="32">
                        </div>
                        <div class="report_type report_store">
                           <p class="type_titlle">举报内容：</p>
                           <textarea class="report_content" name="explain" id="" placeholder=""  maxlength="256"></textarea>
                        </div>
                    </div>
                    <button type="button" class="content_submit">提交</button>
                </form>
            </div>
        </div>
    </div>
</div>

@include('web.layout.footer')
<script>
    $(function(){
      $(".content_submit").on('click',function(){
        var report_type_id = $(".type_choise").val();
        var product_name = $(".goods_name").val();
        var shop_name = $(".store_name").val();
        var explain = $(".report_content").val();
        console.log(report_type_id,product_name,shop_name,explain)
        //---------------------举报类型
        if(!report_type_id){
          layer.alert("请选择要举报的类型!",{icon: 0});
          return false;
        }
        //---------------------举报商品
        if(!product_name){
          layer.alert("请填写举报的商品!",{icon: 0});
          return false;
        }
        //---------------------举报店铺
        if(!shop_name){
          layer.alert("请填写举报的店铺!",{icon: 0});
          return false;
        }
        //---------------------举报内容
        if(!explain){
          layer.alert("请填写举报的内容!",{icon: 0});
          return false;
        }
          $.ajax({
          url: "/member/buyer/report",
          type: "post",
          data: {report_type_id:report_type_id,product_name:product_name,explain:explain,shop_name:shop_name},
          dataType:'json',
          success:function(data){
            if (data.code == 0) {
                layer.alert("信息提交成功，等待商家处理！",{icon:1},function(){
                  location.href = '/member/buyer/report';
                })
            } else {
                layer.alert(data.message, {icon: 2});
            }
          }
        })
      })
    })
</script>
</body>
</html>